<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>微服务工作流系统</title>
<link rel="icon" href="/fk-acti/web/resource/img/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="https://yun.eqbidding.com/extjs/extjs6.0/classic/theme-crisp/resources/theme-crisp-all.css"></link>
<script src="https://yun.eqbidding.com/extjs/extjs6.0/ext-all.js"></script>
<script src="https://yun.eqbidding.com/extjs/extjs6.0/classic/locale/locale-zh_CN.js"></script>
<script type="text/javascript" src="/fk-acti/web/resource/js/app.js"></script>

<!-- 顶部  -->
<script type="text/javascript">
	var button = Ext.create("Ext.Button", {
		text : "控制面板",
		//iconCls: "menu-button",
		icon : jcapp.getIcon("application_side_list.png"),
		menu : {
			items : [ {
				text : '系统信息',
				handler : function() {
					var title = "系统信息";
					var code = "020040";
					var url = "/fk-acti/web/view_setting/list.html";

					openTab(title, code, url);
				}
			}, {
				text : '密码修改',
				handler : function() {
					var title = "密码修改";
					var code = "pwdchange";
					var url = "/fk-acti/web/view_auth/admin/pwd.html";

					openTab(title, code, url);
				}
			} ]
		}
	}).showMenu();
	
	function quit(){
		Ext.Ajax.request({
            url: getServerHttp()+'/loginout',
            method:'post',
            success: function (response) {	      
            	var obj = Ext.JSON.decode(response.responseText);
	           		 window.location="/fk-acti/web/index.html";
                //Ext.MessageBox.alert('成功', '从服务端获取结果: ' + response.responseText);
            },
            failure: function (response, options) {
                Ext.MessageBox.alert('失败', '请求超时或网络故障,错误编号：' + response.status);
            }
        });
	}
	
	var logoutButton = Ext.create("Ext.Button", {

		text : "退出系统",
		icon : jcapp.getIcon("application_side_expand.png"),
		//iconCls: "menu-button",
		handler : function() {
			Ext.Msg.confirm("提示:", "确认退出吗?", function(e) {
				if (e == "yes") {
					quit();
				}//#if yes
			});
			Ext.Msg.defaultFocus = 'no' ;
		},
	});
	var panelHeight = 60;
	var topPanel = Ext.create('Ext.panel.Panel', {
		region : 'north',
		height : panelHeight,
		layout : 'column',
		border : false,
		items : [ {
			xtype : 'panel',
			columnWidth : .50,
			height : panelHeight,
			bodyStyle : "padding-top:0px;background-color:#DEECFD;",
			//html : '<img src="../../resource/img/head.png?9" height="60" />',
			html : '<div style="font-size:20px;padding:20px 0px 0px 10px;">微服务工作流子系统<div>',
			border : false
		}, {
			//title: 'Width = 75%',
			columnWidth : .50,
			height : panelHeight,
			bodyStyle : "background-color:#DEECFD;",
			//html: 'Content',
			border : false
		}, {//title: 'Width = 250px',
			xtype : 'panel',
			autoWidth : true,
			height : panelHeight,
			bodyStyle : "padding-top:30px;background-color:#DEECFD;",
			items : [ button ],
			border : false
		}, {
			//title: 'Width = 250px',
			xtype : 'panel',
			width : 150,
			height : panelHeight,
			bodyStyle : "padding-top:30px;padding-left:20px;background-color:#DEECFD;",
			items : [ logoutButton ],
			border : false
		},{
			xtype : 'panel',
			width : 180,
			id : 'uname',
			height : panelHeight,
			bodyStyle : "padding-top:28px;background-color:#DEECFD;",
			html : "<div style='background-color:#DEECFD;margin-top:5px;font-size:14px;margin-right:20px;'>当前用户:<span style='color:red;'>admin</span></div>",
			border : false
		} ]
	});
	
	</script>
<!-- 左侧菜单 -->
<style type="text/css">
<!--
.x-tree-node-text, .x-accordion-hd {
	cursor: pointer;
}
-->
</style>	
	<script type="text/javascript">
	function openTab(title, code, url) {
		var tabId = "tab_" + code;
		var panel = Ext.getCmp(tabId);
		if (!panel) {
			var href = "" + url;
			var content = '<iframe id="iframe_'+tabId+'" scrolling="yes" frameborder="0"  src="' + href + '" style="width:100%;height:100%;"></iframe>';
			panel = new Ext.Panel({
				id : tabId,
				title : title,
				closable : true,
				bodyPadding : 0,
				html : content
			});
			Ext.getCmp('tabpanels').add(panel);
		}else{

			//判断是否开发模式
			//if(IS_DEVELOP == '是'){
				document.getElementById("iframe_"+tabId).contentWindow.location.reload(true);
			//}
			
		}
		Ext.getCmp('tabpanels').setActiveTab(panel);
	}
	
	function closeTab(code){
		var tabId = "tab_" + code;
		var panel = Ext.getCmp(tabId);
		if (panel) {
			panel.close();
		}
	}

	var leftPanel;
	var IS_DEVELOP = "否";
	Ext.onReady(function() {
		/*
		Ext.Ajax.request({
			url : '/shop/frame/system_info?key=IS_DEVELOP',
			success : function(response) {
				var json = Ext.JSON.decode(response.responseText);
				IS_DEVELOP = json.IS_DEVELOP;
			},
			method : 'post'
		});
		*/
		/** 
		 * 组建树 
		 */
		var buildTree = function(json) {
			var viewTree = Ext.create('Ext.tree.Panel', {
				rootVisible : false,
				border : false,
				store : Ext.create('Ext.data.TreeStore', {
					root : {
						expanded : true,
						children : json.children
					}
				}),
				listeners : {
					'itemclick' : function(view, record, item, index, e) {
						if (record.isLeaf()) {
							var title = record.get("text");
							var code = record.get("id");
							var url = record.get("url");
							openTab(title, code, url);

						} else {
							//关闭节点
							//console.log(viewTree);
						} //#if
					},
					scope : this
				}
			});
			viewTree.expandAll();
			return viewTree;
		};
		/** 
		 * 左,panel.Panel 
		 */
		leftPanel = Ext.create('Ext.panel.Panel', {
			region : 'west',
			title : '导航栏',
			width : 230,
			layout : 'accordion',
			collapsible : true,
			listeners : {
				collapse : function(o,ep){
					var active_tab = Ext.getCmp("tabpanels").getActiveTab();
					var obj = document.getElementById("iframe_"+active_tab.id);
					if(obj != null){
						obj.contentWindow.location.reload(true);
					}
				},
				expand : function(o,ep){
					var active_tab = Ext.getCmp("tabpanels").getActiveTab();
					var obj = document.getElementById("iframe_"+active_tab.id);
					if(obj != null){
						obj.contentWindow.location.reload(true);
					}
				}
			}
		});
		
		loadMenu();
		/** 
		 * 加载菜单树 
		 */
		function loadMenu(){
			var json = [{"kid":"NZwqa6kNWyj27Gq2W7VHav","code":"010","icon":"","url":"","type":"菜单","system":"商户","status":0,"created":1468376164264,"id":"010","iconCls":"","text":"工作流管理","leaf":false,
								"children":[
										{"kid":"S9s8qYzqKxk3kG3KgGvTa8","id":"020010","code":"020010","icon":"","url":"/fk-acti/web/view_activiti/form_management/form_type_management/list.html","type":"菜单","system":"商户","status":0,"created":1468572457918,"iconCls":"","text":"表单管理","leaf":true},	
										{"kid":"S9s8qYzqKxk3kG3KgGvTa1","id":"010010","code":"010010","icon":"","url":"/fk-acti/web/view_activiti/process_management/workflow_model/list.html","type":"菜单","system":"商户","status":0,"created":1503364402817,"iconCls":"","text":"工作流模型","leaf":true},
										{"kid":"S9s8qYzqKxk3kG3KgGvTa2","id":"010020","code":"010020","icon":"","url":"/fk-acti/web/view_activiti/process_management/workflow_definition/list.html","type":"菜单","system":"商户","status":0,"created":1503364402817,"iconCls":"","text":"工作流定义","leaf":true},
										{"kid":"S9s8qYzqKxk3kG3KgGvTa3","id":"010030","code":"010030","icon":"","url":"/fk-acti/web/view_activiti/process_management/workflow_instance/list.html","type":"菜单","system":"商户","status":0,"created":1503364402817,"iconCls":"","text":"工作流实例","leaf":true},
										{"kid":"S9s8qYzqKxk3kG3KgGvTa4","id":"010040","code":"010040","icon":"","url":"/fk-acti/web/view_activiti/process_management/todo_tasks/list.html","type":"菜单","system":"商户","status":0,"created":1503364402817,"iconCls":"","text":"我的待办","leaf":true},
										{"kid":"S9s8qYzqKxk3kG3KgGvTa5","id":"010050","code":"010050","icon":"","url":"/fk-acti/web/view_activiti/process_management/hastodo_tasks/list.html","type":"菜单","system":"商户","status":0,"created":1503364402817,"iconCls":"","text":"我的已办","leaf":true},
										{"kid":"S9s8qYzqKxk3kG3KgGvTa6","id":"010070","code":"010070","icon":"","url":"/fk-acti/web/view_activiti/process_management/my_entrust/list.html","type":"菜单","system":"商户","status":0,"created":1503364402817,"iconCls":"","text":"我的委托","leaf":true},
										{"kid":"S9s8qYzqKxk3kG3KgGvTa8","id":"010080","code":"010080","icon":"","url":"/fk-acti/web/view_activiti/process_management/approval_monitor/list.html","type":"菜单","system":"商户","status":0,"created":1503364402817,"iconCls":"","text":"流程监控","leaf":true},
										{"kid":"S9s8qYzqKxk3kG3KgGvTa7","id":"010060","code":"010060","icon":"","url":"/fk-acti/web/view_activiti/process_management/entrusted_management/list.html","type":"菜单","system":"商户","status":0,"created":1468572457918,"iconCls":"","text":"委托管理","leaf":true},	
								],"expanded":false},
						
						];
			Ext.each(json, function(el) {
				var panel = Ext.create('Ext.panel.Panel', {
					id : el.id,
					title : el.text,
					layout : 'fit'
				});
				panel.add(buildTree(el));
				leftPanel.add(panel);
			});
		}
		function loadMenu1(){
			Ext.Ajax.request({
				url :  getServerHttp()+'/cp/frame/left_data',
				success : function(response) {
					var json = Ext.JSON.decode(response.responseText)
					Ext.each(json.result, function(el) {
						console.log(el);
						var panel = Ext.create('Ext.panel.Panel', {
							id : el.code,
							title : el.text,
							layout : 'fit'
						});
						panel.add(buildTree(el));
						leftPanel.add(panel);
					});
				},
				failure : function(request) {
					Ext.MessageBox.show({
						title : '操作提示',
						msg : "连接服务器失败",
						buttons : Ext.MessageBox.OK,
						icon : Ext.MessageBox.ERROR
					});
				},
			});
		}
		
		var win = Ext.create('Ext.container.Viewport', {
			layout : "border",
			items : [ topPanel, leftPanel, {
				region : 'center',
				id : 'tabpanels',
				xtype : 'tabpanel',
				items : [ {
					title : '主页',
					id: 'toppage',
					html : '<div style="padding:20px;">欢迎登陆微服务工作流子系统 ^_^</div>'
					//items:[listGridPanel3,listGridPanel]//,listGridPanel2
				} ]
			} ],
			renderTo : Ext.getBody()
		});
		
		//Ext.getCmp('tabpanels').add({title: '测试',html: 'Hello world 3',closable: true});
	});
	
</script>
</head>
<body>
</body>
</html>
